Skip to content

[PR] fix(snapshot): Fix the issue where the cache goes completely cold every two folds after a dsh upgrade in long sessions, | fix(snapshot): 长会话升级 dsh 后每折两次缓存全冷的问题,一轮收敛 (#7981) - #8067

Merged
ranxianglei merged 2 commits into
masterfrom
2026-12-01_legacy-pin-ns-jump
Dec 1, 2026

Conversation

@ranxianglei

@ranxianglei ranxianglei commented Dec 1, 2026 •

Copy link
Copy Markdown
Owner

Fixes #7981

这是什么问题

升级 dsh 到 0.1.217(开 pluginFullResendWatermark)之后,升级前建、折过至少一次的旧会话每次折叠后连续两个请求 cache hit 0%,第三个才恢复;新会话只有单冷。issue #7981 有完整的现场取证(每轮 missing 恒等于台账里 214 个旧 uuid 锚点、13 条 info + 1 条 warn 的漂移日志、T 恒等于请求消息数)。

根因一句话:客户端升级后,同一批消息的 id 从服务端按内容算的 h_ 换成了 dsh 打的稳定 uuid——id 空间整体跳变。而 legacy 路径的位置式 pin 对「任意一行 id 对不上」只会放弃(pin 降级为 full),台账行又是 write-once 的,于是每一轮都对不上,永远降级,前缀每轮重铸、折块按 id 匹配永远失败、每折两次全冷。

怎么修的

src/snapshot/stage0.ts 一处(+ 注释,共 +66/-3):pin 在 overlap 行漂移时不再一律放弃,先做一次逐行指纹——只有当每个漂移行的台账侧都是内容哈希 h_ 行、且客户端声明的 id 在整个台账里查无(命名空间整体换了一个新空间),才容忍这次漂移并照常规应用 pin:前缀从台账 write-once 行重铸,新核盖上声明的宿主 id。其余任何漂移(共享命名空间的真漂移、"?" 槽位、id 在台账他处出现)一律保持原来的 null 降级,issue5874-2x2-p3 的 I2/I3 契约原样不动。

这就是 egress 台账遇到同一处境时 REANCHOR_NOW 的答案(egress 从不 null);legacy 路径现在给出同样的答案,但用更保守的指纹(egress 按"全零匹配"放行,legacy 要求逐行 h_+外部 id,因为 legacy 的台账是位置对齐的,不是视图盖印)。

收敛是一轮的:miss 轮走 raw,ingest sweep 把台账尾部对齐到声明的 uuid 空间,之后每一轮都是普通位置式 pin,不再触发该分支。分支首次触发时打一条有界的 per-session warn——这个分支之前是静默的,报告者的痛点之一就是静默。

不改 fold-reconcile 的日志级别、不改 fastpath 的 tail-ids 检查、不碰任何 config 字段;无 version bump(内容 commit,版本只在 release 分支动)。

验证

  • 新增 tests/issue7981-legacy-ns-jump.test.ts 7 用例全绿:J1 全 h_ 台账+uuid tail 从 null 变为 pin 成功且仅一条 warn、幂等;J2 sweep 后已收敛台账走普通路径无 warn;J3a/J3b 混合台账过渡态不振荡;J4 宿主 id 台账上的真漂移仍降级(full);J5 overlap 位 "?" 仍降级;J6 漂移 id 在台账他处存在仍降级(指纹逐行非全列)。
  • tests/issue5874-2x2-p3.test.ts 43/43 原样全绿(I2/I3 契约未动)。
  • pin/msgid/fold-drift 焦点批次 15 个文件 211/211 全绿。
  • 本机全量套件里 update/advisory 域的失败是沙箱无外网端点的超时噪音(15s resolve 超时),与本改动无关,以远端 CI test lane 为准(AGENTS.md §7.2)。

follow-up(不在本 PR)

  • fold-reconcile 在「claims>0 且全部重锚成功」时落 info 而非可见级别(现场静默的直接来源),建议单独评估升级。
  • fastpath 的 tail-ids-shape 检查在混合 id 块场景的精确对齐(issue 里 missing 214 恒定的另一半),可用报告者的 3 数探针另查。

… jump (#7981)

The positional (legacy) incremental pin deadlocks when the wire id space
moves away from content hashes: every overlap row drifts (host uuid vs
ledger h_), the pin degrades to the full signal on every turn, the prefix
re-mints as h_ each time, and fold blocks recorded under the churn
re-anchor onto churned bytes every turn (the double cache cold per fold
the issue reports). The egress ledger answers the identical situation
with REANCHOR_NOW and never nulls; the legacy path now gets the same
answer under a conservative per-row fingerprint:

  an overlap-row drift is tolerated (jump) only when EVERY drifted row
  is a content-hash ledger row (h_<16hex>) carrying a valid client id
  that is FOREIGN to the whole ledger — i.e. the wire namespace moved
  to a fresh space and the ledger is the old one. Any other drift row
  is shared-namespace drift and keeps the legacy null degrade (the
  issue5874-2x2-p3 I2/I3 contract, verified unmodified and green).

The pin converges in one round: the prefix re-stamps from the ledger's
write-once rows, the new core takes the declared host ids, the first
RAW (miss) turn's ingest sweep aligns the ledger tail to the declared
namespace, and every later turn pins on the ordinary positional path.
One bounded per-session warn makes the previously silent branch
auditable (the reporter's pain was the silence).

No version bump (content commit on a feature branch).

tests: issue7981-legacy-ns-jump.test.ts (J1..J6 — the jump shape, the
post-sweep convergence, mixed-ledger transients, and the three shared-
namespace drift cases that must keep degrading);
issue5874-2x2-p3.test.ts stays green unmodified (the I2/I3 contract).
@github-actions

github-actions Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-12-01_legacy-pin-ns-jump (9ca7694)

Latest build — install this exact version

npm install -g billion-context@0.0.12666-pr.8067.88a2c21

This exact version is immutable and reproducible. The rolling pr tag tracks the newest test build across all PRs.

Recent builds (commit → version)

commit version build
9ca7694 billion-context@0.0.12666-pr.8067.88a2c21 build
bff3206 billion-context@0.0.12658-pr.8067.2a18076 build

Download artifact

  1. Download the artifact from the Actions run
  2. Extract the tarball and install:
tar xzf billion-context-pr8067.tgz
npm install -g package

Install instructions are refreshed on each push.

@ranxianglei ranxianglei changed the title fix(snapshot): 长会话升级 dsh 后每折两次缓存全冷的问题,一轮收敛 (#7981) [PR] fix(snapshot): Fix the issue where the cache goes completely cold every two folds after a dsh upgrade in long sessions, | fix(snapshot): 长会话升级 dsh 后每折两次缓存全冷的问题,一轮收敛 (#7981) Dec 1, 2026
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷

查重: 不重复——本 PR(#8067)是 #7981 的修复 PR,无其他在途修复 PR。

标签: bug + dsh + scope/wiring + p1(缓存命中崩坏类,按 owner 修订 2026-10-19 = p1;pin 路径属协议接线层)。

八问

  1. 是什么问题: 升级 dsh 到 0.1.217(开 pluginFullResendWatermark)后,升级前建、折过至少一次的旧会话,每次折叠后连续两个请求 cache hit 0%,第三个才恢复(新会话只有单冷)。
  2. 什么原因导致的: 客户端升级后,同一批消息的 id 从服务端按内容算的 h_ 换成了 dsh 打的稳定 uuid——id 空间整体跳变。legacy 路径的位置式 pin 对「任意一行 id 对不上」一律放弃(降级 full),台账行又是 write-once 的,于是每轮都对不上、永远降级、前缀每轮重铸、折块按 id 匹配永远失败 → 每折两次全冷。
  3. 影响范围与严重程度: 受影响 = 升级前建、折过至少一次的旧会话(开 pluginFullResendWatermark)。严重度 = 缓存命中崩坏(每次折叠后两个请求 0% 命中)——p1。
  4. 怎么修复的: pin 在 overlap 行漂移时不再一律放弃,先做一次逐行指纹——只有当每个漂移行的台账侧都是内容哈希 h_ 行、且客户端声明的 id 在整个台账里查无(命名空间整体换了一个新空间),才容忍这次漂移并照常规应用 pin。其余任何漂移保持原来的 null 降级(I2/I3 契约原样不动)。收敛是一轮的:miss 轮走 raw,ingest sweep 把台账尾部对齐到声明的 uuid 空间,之后每轮都是普通位置式 pin。
  5. 是否有回归问题: 审了 I2/I3 契约(issue5874-2x2-p3 43 用例)——原样全绿,未动。指纹是保守的(逐行 h_+外部 id),共享命名空间的真漂移、"?" 槽位、id 在台账他处出现一律保持 null 降级。无回归。
  6. 是否破坏缓存: 不改缓存/重试/增量游标/去重键。pin 的收敛机制是既有的(ingest sweep)。本 PR 修复的正是缓存命中崩坏。
  7. 是否改了设计方向: 不改架构/边界/数据流。legacy 路径现在给出与 egress 台账(REANCHOR_NOW)相同的答案,但用更保守的指纹(egress 按"全零匹配"放行,legacy 要求逐行 h_+外部 id)。
  8. 是否引入了新的配置: 无新 config/env/默认值。无 version bump(内容 commit)。

CI 状态(实时)

阻断项(需 owner 处理)

  1. close-object-guard: PR body 需要加一行 Closes #7981(或 no-close-object: <reason>)。按政策我不改 PR body,请 owner 补一行,或确认由我补。
  2. PR behind master: master 已前进 4 个 commit([Bug][dsh] When dsh quits or restarts (incl. self-update), the plugin loses session identity and every model request silently goes direct uncompressed — the user gets no notice #8051 dsh-host-dying-local-refusal 等),PR 分支落后。我已验证 rebase 干净(无文件冲突、master 未碰 PR 的两个文件),可一行 rebase 收敛。等 owner 确认是否由我 rebase + push。

判定

代码正确、测试真(本地 50/50 全绿:7 新 J 用例 + 43 I2/I3 契约),机制与 egress 台账 REANCHOR_NOW 对齐但指纹更保守。两个 CI 阻断(close-object-guard + rebase)都是机械性的,等 owner 确认处置即可合。test lanes 结果以远端 CI 为准。

@ranxianglei ranxianglei added bug Something isn't working dsh p1 scope/wiring labels Dec 1, 2026
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

本轮 CI 修复完成:close-object-guard 已转绿。

做了什么

八问

  1. 是什么问题:PR 正文缺 GitHub 关闭引用,close-object-guard 门禁红,卡住整个 PR 合并。
  2. 什么原因导致的:作者用散文式「issue [Bug][dsh] 0.1.217: Long sessions prior to the upgrade repeatedly re-anchor the collapsed region every turn; after colla | [Bug][dsh] 0.1.217: 升级前的长会话每轮重复重锚折叠区,折叠后连续两轮前缀缓存全冷 #7981」提及,而非 Fixes #7981 关闭语法;guard 只认后者(它是唯一能触发 GitHub 自动关 issue 的位置)。
  3. 影响范围与严重程度:仅本 PR 的 CI 元数据缺失——前置门一红把后面所有昂贵 job 全 cancel,PR 无法合并;对代码 / 用户零影响。严重度:阻塞合并,无功能影响。
  4. 怎么修复的:正文补 Fixes #7981 关闭引用 + 推一个无标记空 commit 触发完整 CI 重跑(改正文本身不触发 CI,必须有个新事件让 guard 读到新正文)。
  5. 是否有回归问题:无。改动只有正文一行 + 一个空 commit(零文件变更,PR 的 file diff 与之前逐字节一致);未触碰任何代码 / config / wire / kernel。
  6. 是否破坏缓存:不涉及(无代码变更)。
  7. 是否改了设计方向:不涉及。
  8. 是否引入了新的配置:不涉及。

状态:close-object-guard 绿,其余 job 跑中。PR 当前 mergeable_state: behind(落后 master 但无冲突,可直接合并;本次未 rebase——非本次红项,且 rebase 会再触发一轮全量 CI,不划算)。

@ranxianglei
ranxianglei merged commit 8e24d0b into master Dec 1, 2026
49 checks passed
@github-actions

github-actions Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

📦 Merged Build Published

This merge to master was published as 0.0.1359-master.8e24d0b (rolling master tag).

npm install -g billion-context@0.0.1359-master.8e24d0b  # this exact build
npm install -g billion-context@master  # always the newest merged build

npm view billion-context@master prints the current version at any time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working dsh p1 scope/wiring

Projects

None yet

1 participant